'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    /**
     * Add seed commands here.
     *
     * Example:
     * await queryInterface.bulkInsert('People', [{
     *   name: 'John Doe',
     *   isBetaMember: false
     * }], {});
    */
    return queryInterface.sequelize.transaction(async t => {

      await queryInterface.bulkInsert("sys_dept", [{
        dept_id: 100,
        parent_id: 0,
        ancestors: "0",
        dept_name: "若伊",
        order_num: 0,
        leader: "若伊",
        phone: "15888888888",
        email: "ruoyi@163.com",
        create_by: "admin",
        status: "0",
        created_at: new Date(),
        updated_at: new Date(),
      }, {
        dept_id: 101,
        parent_id: 100,
        ancestors: "0,100",
        dept_name: "深圳总公司",
        order_num: 1,
        leader: "若伊",
        phone: "15888888888",
        email: "ruoyi@163.com",
        create_by: "admin",
        status: "0",
        created_at: new Date(),
        updated_at: new Date(),
      }, {
        dept_id: 102,
        parent_id: 100,
        ancestors: "0,100",
        dept_name: "长沙分公司",
        order_num: 2,
        leader: "若伊",
        phone: "15888888888",
        email: "ruoyi@163.com",
        create_by: "admin",
        status: "0",
        created_at: new Date(),
        updated_at: new Date(),
      }, {
        dept_id: 103,
        parent_id: 101,
        ancestors: "0,100,101",
        dept_name: "研发部门",
        order_num: 1,
        leader: "若伊",
        phone: "15888888888",
        email: "ruoyi@163.com",
        create_by: "admin",
        status: "0",
        created_at: new Date(),
        updated_at: new Date(),
      }, {
        dept_id: 104,
        parent_id: 101,
        ancestors: "0,100,101",
        dept_name: "市场部门",
        order_num: 2,
        leader: "若伊",
        phone: "15888888888",
        email: "ruoyi@163.com",
        create_by: "admin",
        status: "0",
        created_at: new Date(),
        updated_at: new Date(),
      }, {
        dept_id: 105,
        parent_id: 101,
        ancestors: "0,100,101",
        dept_name: "测试部门",
        order_num: 3,
        leader: "若伊",
        phone: "15888888888",
        email: "ruoyi@163.com",
        create_by: "admin",
        status: "0",
        created_at: new Date(),
        updated_at: new Date(),
      }, {
        dept_id: 106,
        parent_id: 101,
        ancestors: "0，100，101",
        dept_name: "财务部门",
        order_num: 4,
        leader: "若伊",
        phone: "15888888888",
        email: "ruoyi@163.com",
        create_by: "admin",
        status: "0",
        created_at: new Date(),
        updated_at: new Date(),
      }, {
        dept_id: 107,
        parent_id: 101,
        ancestors: "0,100,101",
        dept_name: "运维部门",
        order_num: 5,
        leader: "若伊",
        phone: "15888888888",
        email: "ruoyi@163.com",
        create_by: "admin",
        status: "0",
        created_at: new Date(),
        updated_at: new Date(),
      }, {
        dept_id: 108,
        parent_id: 102,
        ancestors: "0,100,102",
        dept_name: "市场部门",
        order_num: 1,
        leader: "若伊",
        phone: "15888888888",
        email: "ruoyi@163.com",
        create_by: "admin",
        status: "0",
        created_at: new Date(),
        updated_at: new Date(),
      }, {
        dept_id: 109,
        parent_id: 102,
        ancestors: "0,100,102",
        dept_name: "财务部门",
        order_num: 0,
        leader: "若伊",
        phone: "15888888888",
        email: "ruoyi@163.com",
        create_by: "admin",
        status: "0",
        created_at: new Date(),
        updated_at: new Date(),
      }])
    })
  },

  down: async (queryInterface, Sequelize) => {
    /**
     * Add commands to revert seed here.
     *
     * Example:
     * await queryInterface.bulkDelete('People', null, {});
     */
     return queryInterface.sequelize.transaction(async t => {
      return await queryInterface.bulkDelete("sys_dept", null, { transaction: t });
    })
  }
};
